package com.yuxh.blog.service;

import com.yuxh.blog.model.SomeSay;
import com.yuxh.blog.repository.SomeSayRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

@Service
public class SomeSayService {

    @Autowired
    private SomeSayRepository someSayRepository;

    public Page<SomeSay> list(Integer pageNumber, Integer pageSize) {
        Pageable pageable = PageRequest.of(pageNumber - 1, pageSize, Sort.by(Sort.Direction.DESC, "createTime"));
        Page<SomeSay> postIn = someSayRepository.findAll(pageable);
        return postIn;
    }

}
